package org.duang.db.sql.parser.encode;

import java.util.List;

import org.duang.db.mongo.Operator;
import org.duang.db.sql.SqlObject;
import org.duang.kit.ToolsKit;

public abstract class SqlEncoder {

	protected String key;
	protected String opt;
	protected Object obj;
	
	public SqlEncoder(String key , String opt,  Object obj) {
		this.key = key;
		this.opt = opt;
		this.obj = obj;
	}
	
	public boolean isNull(){
		return null == obj;
	}
	
	
	public String getOpt() {
		if(isNull()){
			throw new NullPointerException("obj is null");
		}
		String optTmp = Operator.SQL_OPERATOR_MAP.get(opt);
		return ToolsKit.isEmpty(optTmp)  ?  "=" : optTmp;
	}
	
	public abstract  List<SqlObject> getValue();
	
}
